*, *::before, *::after { box-sizing: border-box; }

.gallery-section {
    background-color: #F8F9FA;
    padding: 6rem 15%;
    font-family: 'Tajawal', sans-serif;
}

.gallery-section .gallery-container { max-width: 1280px; margin: 0 auto; }

/* إخفاء مبدئي للـ GSAP لمنع الـ FOUC */
.gallery-section .sub-title,
.gallery-section .main-title,
.gallery-section .title-line,
.gallery-section .gallery-filters, 
.gallery-section .gallery-item {
    opacity: 0;
    visibility: hidden;
}

/* --- العناوين --- */
.gallery-section .section-header { text-align: center; margin-bottom: 3.5rem; }
.gallery-section .sub-title { color: var(--gold-dark, #9B7D23); font-size: 1.1rem; font-weight: 700; margin-bottom: 0.5rem; display: block; }
.gallery-section .main-title { color: var(--primary, #0A1128); font-size: 2.5rem; font-weight: 800; margin-bottom: 1rem; }
.gallery-section .title-line { width: 60px; height: 3px; background-color: var(--gold, #D4AF37); margin: 0 auto; border-radius: 3px; }

/* --- أزرار الفلترة --- */
.gallery-section .gallery-filters { display: flex; justify-content: center; flex-wrap: wrap; gap: 1rem; margin-bottom: 3.5rem; }
.gallery-section .filter-btn { background-color: transparent; color: #475569; border: 2px solid #CBD5E1; padding: 0.6rem 1.8rem; border-radius: 50px; font-family: 'Tajawal', sans-serif; font-size: 1.05rem; font-weight: 600; cursor: pointer; transition: all 0.3s ease; }
.gallery-section .filter-btn:hover { border-color: var(--gold, #D4AF37); color: var(--primary, #0A1128); }
.gallery-section .filter-btn.active { background-color: var(--primary, #0A1128); color: #FFFFFF; border-color: var(--primary, #0A1128); box-shadow: 0 5px 15px rgba(10, 17, 40, 0.2); }

/* --- شبكة الصور --- */
.gallery-section .gallery-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2rem; }
.gallery-section .gallery-item { transition: all 0.4s ease; }
.gallery-section .gallery-item.hide { display: none !important; }
.gallery-section .gallery-card { position: relative; border-radius: 16px; overflow: hidden; height: 300px; box-shadow: 0 10px 20px rgba(0, 0, 0, 0.08); cursor: pointer; }
.gallery-section .gallery-img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.5s ease; }

.gallery-section .gallery-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(to top, rgba(10, 17, 40, 0.95) 0%, rgba(10, 17, 40, 0.4) 60%, transparent 100%);
    display: flex; flex-direction: column; justify-content: flex-end; padding: 2rem;
    opacity: 0; transition: opacity 0.4s ease;
}
.gallery-section .gallery-category { color: var(--gold, #D4AF37); font-size: 0.9rem; font-weight: 700; margin-bottom: 0.4rem; transform: translateY(15px); transition: transform 0.4s ease; }
.gallery-section .gallery-item-title { color: #FFFFFF; font-size: 1.2rem; font-weight: 700; line-height: 1.4; margin: 0 0 1rem 0; transform: translateY(15px); transition: transform 0.4s ease; }
.gallery-section .gallery-zoom-icon { width: 40px; height: 40px; background-color: var(--gold, #D4AF37); color: var(--primary, #0A1128); border-radius: 50%; display: flex; justify-content: center; align-items: center; font-size: 1rem; transform: translateY(15px); transition: transform 0.4s ease, background-color 0.3s ease; }

.gallery-section .gallery-card:hover .gallery-img { transform: scale(1.08); }
.gallery-section .gallery-card:hover .gallery-overlay { opacity: 1; }
.gallery-section .gallery-card:hover .gallery-category,
.gallery-section .gallery-card:hover .gallery-item-title,
.gallery-section .gallery-card:hover .gallery-zoom-icon { transform: translateY(0); }

/* --- Lightbox Modal --- */
.gallery-modal { display: none; position: fixed; z-index: 9999; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(10, 17, 40, 0.95); backdrop-filter: blur(10px); justify-content: center; align-items: center; flex-direction: column; padding: 2rem; }
.gallery-modal.show { display: flex; }
.gallery-modal .modal-content-img { max-width: 85%; max-height: 80vh; border-radius: 12px; border: 2px solid var(--gold, #D4AF37); box-shadow: 0 25px 50px rgba(0,0,0,0.5); }
.gallery-modal .modal-caption { color: #FFFFFF; font-size: 1.3rem; font-weight: 700; margin-top: 1.5rem; text-align: center; }
.gallery-modal .modal-close { position: absolute; top: 30px; left: 40px; color: var(--gold, #D4AF37); font-size: 3rem; font-weight: bold; cursor: pointer; transition: transform 0.3s ease; }
.gallery-modal .modal-close:hover { transform: scale(1.2); }

@media (max-width: 992px) {
    .gallery-section {
        padding: 5rem 6%;
    }
    .gallery-section .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .gallery-section {
        padding: 3.5rem 1rem !important;
        overflow: hidden !important;
    }
    .gallery-section .gallery-container {
        width: 100% !important;
        max-width: 100% !important;
        overflow: hidden !important;
        padding: 0 !important;
    }
    .gallery-section .section-header {
        margin-bottom: 2rem;
    }
    .gallery-section .main-title {
        font-size: 1.85rem;
    }

    /* شريط تابات الصور كسطر واحد متحرك أفقياً وسلس السحب */
    .gallery-section .gallery-filters {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        scroll-behavior: smooth !important;
        scrollbar-width: none !important; /* Firefox */
        -ms-overflow-style: none !important; /* IE / Edge */
        justify-content: flex-start !important;
        gap: 0.55rem !important;
        padding: 4px 6px 12px 6px !important;
        margin-bottom: 2rem !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    .gallery-section .gallery-filters::-webkit-scrollbar {
        display: none !important;
        width: 0 !important;
        height: 0 !important;
    }
    .gallery-section .gallery-filters .filter-btn {
        flex: 0 0 auto !important;
        white-space: nowrap !important;
        padding: 0.42rem 1.15rem !important;
        font-size: 0.85rem !important;
        font-weight: 600 !important;
        border-radius: 50px !important;
        border-width: 1.5px !important;
        touch-action: pan-x !important;
    }
    .gallery-section .gallery-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    .gallery-section .gallery-card {
        height: 240px;
    }
    .gallery-section .gallery-overlay {
        padding: 1.2rem;
    }
    .gallery-section .gallery-item-title {
        font-size: 1.05rem;
        margin-bottom: 0.5rem;
    }
    .gallery-modal {
        padding: 1rem;
    }
    .gallery-modal .modal-content-img {
        max-width: 95%;
        max-height: 70vh;
    }
    .gallery-modal .modal-caption {
        font-size: 1rem;
        margin-top: 1rem;
    }
    .gallery-modal .modal-close {
        top: 15px;
        left: 20px;
        font-size: 2.2rem;
    }
}

/* ==========================================================================
   LTR / English Mode Support
   ========================================================================== */
.gallery-section[dir="ltr"],
.gallery-section.pe-ltr {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    direction: ltr;
}

.gallery-section[dir="ltr"] .filter-btn,
.gallery-section.pe-ltr .filter-btn {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.gallery-section[dir="ltr"] .gallery-overlay,
.gallery-section.pe-ltr .gallery-overlay {
    text-align: left;
    align-items: flex-start;
}

.gallery-section[dir="ltr"] + .gallery-modal .modal-close,
.gallery-section.pe-ltr + .gallery-modal .modal-close {
    left: auto;
    right: 40px;
}

@media (max-width: 768px) {
    .gallery-section[dir="ltr"] + .gallery-modal .modal-close,
    .gallery-section.pe-ltr + .gallery-modal .modal-close {
        left: auto;
        right: 20px;
    }
}