/* 
    ==================================================================
    شركة أغنى | AGHNA Architectural Media Gallery
    Theme: Royal Dark Green (#152019 / #131D17) + Gold Accents (#C5A869)
    Desktop: Uniform 3-Column Luxury Grid + Pagination & Load More
    Mobile/Tablet: Hardware-Accelerated Touch Swipe Carousel (CSS Scroll-Snap)
    ==================================================================
*/

.gallery-section {
    background: linear-gradient(180deg, #152019 0%, #1A271F 50%, #131D17 100%);
    color: #FFFFFF;
    padding: 110px 0;
    position: relative;
    overflow: hidden;
    border-top: 1px solid rgba(197, 168, 105, 0.2);
    border-bottom: 1px solid rgba(197, 168, 105, 0.2);
}

/* Subtle architectural watermark pattern background */
.gallery-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        radial-gradient(circle at 15% 20%, rgba(197, 168, 105, 0.05) 0%, transparent 40%),
        radial-gradient(circle at 85% 80%, rgba(197, 168, 105, 0.04) 0%, transparent 45%);
    pointer-events: none;
    z-index: 0;
}

.gallery-section .container {
    position: relative;
    z-index: 1;
}

/* Section Header */
.gallery-header {
    text-align: center;
    max-width: 820px;
    margin: 0 auto 40px;
}

.gallery-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 20px;
    border-radius: 30px;
    background: rgba(197, 168, 105, 0.12);
    border: 1px solid rgba(197, 168, 105, 0.35);
    color: var(--primary-color, #C5A869);
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 1px;
    margin-bottom: 16px;
    text-transform: uppercase;
}

.gallery-eyebrow i {
    font-size: 0.85rem;
}

.gallery-title {
    font-size: 2.75rem;
    font-weight: 800;
    color: #FFFFFF;
    margin-bottom: 16px;
    line-height: 1.3;
    letter-spacing: -0.5px;
}

.gallery-title span {
    color: var(--primary-color, #C5A869);
    background: linear-gradient(135deg, #DFCA8D 0%, #C5A869 50%, #A08343 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.gallery-subtitle {
    font-size: 1.12rem;
    line-height: 1.8;
    color: rgba(255, 255, 255, 0.75);
    margin: 0 auto;
}

/* Filter Controls */
.gallery-filters {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 45px;
}

.gallery-filter-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.85);
    padding: 10px 24px;
    border-radius: 30px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
    outline: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.gallery-filter-btn:hover {
    background: rgba(197, 168, 105, 0.15);
    border-color: rgba(197, 168, 105, 0.4);
    color: #FFFFFF;
    transform: translateY(-2px);
}

.gallery-filter-btn.active {
    background: var(--primary-color, #C5A869);
    border-color: var(--primary-color, #C5A869);
    color: #131D17;
    font-weight: 700;
    box-shadow: 0 6px 20px rgba(197, 168, 105, 0.35);
}

.gallery-filter-btn:focus-visible {
    box-shadow: 0 0 0 3px rgba(197, 168, 105, 0.6);
}

/* ==================================================================
   DESKTOP: Uniform Architectural 3-Column Luxury Grid
   ================================================================== */
.gallery-bento-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 28px;
    margin-bottom: 35px;
    transition: all 0.4s ease;
}

/* Uniform Card Sizes on Desktop */
.gallery-item {
    position: relative;
    border-radius: 18px;
    overflow: hidden;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: #0E1611;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    height: 380px;
    grid-column: span 1 !important;
    grid-row: span 1 !important;
    transition: transform 0.45s cubic-bezier(0.2, 0.8, 0.2, 1),
                box-shadow 0.45s cubic-bezier(0.2, 0.8, 0.2, 1),
                border-color 0.45s cubic-bezier(0.2, 0.8, 0.2, 1),
                opacity 0.4s ease;
}

.gallery-item:hover {
    transform: translateY(-5px) scale(1.015);
    box-shadow: 0 22px 50px rgba(0, 0, 0, 0.5), 0 0 30px rgba(197, 168, 105, 0.18);
    border-color: rgba(197, 168, 105, 0.55);
}

.gallery-item:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--primary-color, #C5A869);
}

/* ==================================================================
   DESKTOP PAGINATION & ANTI-CLUTTER CONTROLS
   ================================================================== */
@media (min-width: 992px) {
    /* Page 1 mode (default): hide page 2 items unless .show-all is active */
    .gallery-bento-grid:not(.show-all):not([data-current-page="2"]) .gallery-item.page-2-item {
        display: none !important;
    }

    /* Page 2 mode: hide page 1 items unless .show-all is active */
    .gallery-bento-grid[data-current-page="2"]:not(.show-all) .gallery-item:not(.page-2-item) {
        display: none !important;
    }

    /* Show All mode: all items displayed */
    .gallery-bento-grid.show-all .gallery-item {
        display: block !important;
    }

    /* Always respect category filter hidden state */
    .gallery-bento-grid .gallery-item.is-hidden {
        display: none !important;
    }
}

/* Filter Animation States */
.gallery-item.is-hidden {
    display: none !important;
}

/* Media Containers (Images & Videos) */
.gallery-media-wrapper {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    display: block;
}

.gallery-media-wrapper img,
.gallery-media-wrapper video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.gallery-item:hover .gallery-media-wrapper img,
.gallery-item:hover .gallery-media-wrapper video {
    transform: scale(1.045);
}

/* Video specific styles */
.gallery-media-wrapper video {
    background: #000000;
}

.gallery-video-badge {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 3;
    background: rgba(19, 29, 23, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(197, 168, 105, 0.4);
    color: #FFFFFF;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    pointer-events: none;
    transition: all 0.3s ease;
}

[dir="ltr"] .gallery-video-badge {
    right: auto;
    left: 16px;
}

.gallery-video-badge i {
    color: var(--primary-color, #C5A869);
    font-size: 0.75rem;
}

.gallery-item:hover .gallery-video-badge {
    background: var(--primary-color, #C5A869);
    color: #131D17;
}

.gallery-item:hover .gallery-video-badge i {
    color: #131D17;
}

/* Overlay & Card Information */
.gallery-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, 
        rgba(14, 22, 17, 0.05) 0%, 
        rgba(14, 22, 17, 0.35) 45%, 
        rgba(14, 22, 17, 0.94) 100%);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 22px;
    z-index: 2;
    transition: background 0.4s ease;
}

.gallery-item:hover .gallery-overlay {
    background: linear-gradient(180deg, 
        rgba(14, 22, 17, 0.1) 0%, 
        rgba(14, 22, 17, 0.45) 40%, 
        rgba(14, 22, 17, 0.98) 100%);
}

.gallery-card-top {
    position: absolute;
    top: 16px;
    left: 16px;
    z-index: 3;
}

[dir="ltr"] .gallery-card-top {
    left: auto;
    right: 16px;
}

.gallery-zoom-icon {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(19, 29, 23, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(197, 168, 105, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color, #C5A869);
    font-size: 0.9rem;
    opacity: 0;
    transform: scale(0.85);
    transition: all 0.35s ease;
}

.gallery-item:hover .gallery-zoom-icon {
    opacity: 1;
    transform: scale(1);
}

.gallery-card-info {
    position: relative;
    z-index: 3;
    transform: translateY(3px);
    transition: transform 0.35s ease;
}

.gallery-item:hover .gallery-card-info {
    transform: translateY(0);
}

.gallery-project-tag {
    display: inline-block;
    color: var(--primary-color, #C5A869);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}

.gallery-item-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: #FFFFFF;
    margin: 0 0 6px 0;
    line-height: 1.45;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 2.9em;
}

.gallery-item-loc {
    font-size: 0.88rem;
    color: rgba(255, 255, 255, 0.82);
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
}

.gallery-item-loc i {
    color: var(--primary-color, #C5A869);
    font-size: 0.8rem;
}

/* ==================================================================
   DESKTOP PAGINATION & LOAD MORE STYLING
   ================================================================== */
.gallery-pagination-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin: 10px auto 40px;
}

.gallery-pagination {
    display: flex;
    align-items: center;
    gap: 10px;
}

.gallery-page-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(197, 168, 105, 0.35);
    color: var(--primary-color, #C5A869);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    outline: none;
}

.gallery-page-btn:hover:not(:disabled) {
    background: var(--primary-color, #C5A869);
    color: #131D17;
    transform: scale(1.08);
}

.gallery-page-btn:disabled {
    opacity: 0.25;
    cursor: not-allowed;
    border-color: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.3);
}

[dir="ltr"] .gallery-page-btn.prev i,
[dir="ltr"] .gallery-page-btn.next i {
    transform: rotate(180deg);
}

.gallery-page-numbers {
    display: flex;
    align-items: center;
    gap: 8px;
}

.gallery-page-num {
    min-width: 44px;
    height: 42px;
    padding: 0 14px;
    border-radius: 25px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #FFFFFF;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    outline: none;
}

.gallery-page-num:hover {
    border-color: rgba(197, 168, 105, 0.5);
    color: var(--primary-color, #C5A869);
}

.gallery-page-num.active {
    background: var(--primary-color, #C5A869);
    border-color: var(--primary-color, #C5A869);
    color: #131D17;
    box-shadow: 0 4px 15px rgba(197, 168, 105, 0.35);
}

.gallery-load-more-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: rgba(197, 168, 105, 0.1);
    border: 1px solid rgba(197, 168, 105, 0.35);
    color: #FFFFFF;
    padding: 11px 26px;
    border-radius: 30px;
    font-family: inherit;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
    outline: none;
}

.gallery-load-more-btn:hover {
    background: rgba(197, 168, 105, 0.22);
    border-color: var(--primary-color, #C5A869);
    color: var(--primary-color, #C5A869);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(197, 168, 105, 0.25);
}

.gallery-load-more-btn i {
    font-size: 0.85rem;
    transition: transform 0.3s ease;
}

/* ==================================================================
   MOBILE / TABLET SLIDER CONTROLS (Hidden on Desktop)
   ================================================================== */
.gallery-slider-controls {
    display: none; /* Desktop hidden */
    align-items: center;
    justify-content: center;
    gap: 18px;
    margin: 10px auto 35px;
    padding: 0 15px;
}

.gallery-slider-arrow {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(197, 168, 105, 0.4);
    color: var(--primary-color, #C5A869);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.gallery-slider-arrow:hover,
.gallery-slider-arrow:active {
    background: var(--primary-color, #C5A869);
    color: #131D17;
    transform: scale(1.08);
    box-shadow: 0 4px 15px rgba(197, 168, 105, 0.35);
}

.gallery-slider-arrow:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    transform: none;
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.4);
}

/* Flip arrows in LTR (English) */
[dir="ltr"] .gallery-prev-btn i {
    transform: rotate(180deg);
}

[dir="ltr"] .gallery-next-btn i {
    transform: rotate(180deg);
}

.gallery-slider-indicators {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.gallery-slider-counter {
    font-size: 0.95rem;
    font-weight: 700;
    color: #FFFFFF;
    font-variant-numeric: tabular-nums;
    letter-spacing: 1px;
}

.gallery-counter-current {
    color: var(--primary-color, #C5A869);
    font-size: 1.05rem;
}

.gallery-counter-divider {
    color: rgba(255, 255, 255, 0.35);
    margin: 0 4px;
}

.gallery-counter-total {
    color: rgba(255, 255, 255, 0.75);
}

.gallery-slider-dots {
    display: flex;
    align-items: center;
    gap: 6px;
    max-width: 240px;
    overflow-x: auto;
    padding: 4px 2px;
}

.gallery-slider-dot {
    width: 7px;
    height: 7px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.25);
    border: none;
    padding: 0;
    cursor: pointer;
    transition: all 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
    outline: none;
}

.gallery-slider-dot.active {
    width: 22px;
    background: var(--primary-color, #C5A869);
    box-shadow: 0 0 10px rgba(197, 168, 105, 0.6);
}

/* Gallery Footer / CTA */
.gallery-footer {
    text-align: center;
    margin-top: 15px;
}

.gallery-portfolio-btn {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    background: transparent;
    border: 1.5px solid var(--primary-color, #C5A869);
    color: #FFFFFF;
    padding: 14px 34px;
    border-radius: 35px;
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.gallery-portfolio-btn:hover {
    background: var(--primary-color, #C5A869);
    color: #131D17;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(197, 168, 105, 0.35);
}

.gallery-portfolio-btn i {
    transition: transform 0.3s ease;
}

[dir="rtl"] .gallery-portfolio-btn:hover i {
    transform: translateX(-4px);
}

[dir="ltr"] .gallery-portfolio-btn:hover i {
    transform: translateX(4px);
}

/* ==================================================================
   RESPONSIVE BREAKPOINTS: Mobile & Tablet Sliding Carousel
   ================================================================== */
@media (max-width: 991px) {
    .gallery-section {
        padding: 80px 0 70px;
    }

    .gallery-title {
        font-size: 2.2rem;
    }

    .gallery-subtitle {
        font-size: 1.05rem;
    }

    .gallery-filters {
        gap: 8px;
        margin-bottom: 30px;
    }

    .gallery-filter-btn {
        padding: 8px 18px;
        font-size: 0.88rem;
    }

    /* Convert Grid to Smooth Horizontal Touch Slider */
    .gallery-bento-grid {
        display: flex !important;
        flex-direction: row;
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        scroll-snap-type: x mandatory;
        scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch;
        gap: 18px;
        padding: 10px 15px 25px;
        margin-bottom: 20px;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .gallery-bento-grid::-webkit-scrollbar {
        display: none;
    }

    /* All items in mobile slider are visible (unless filtered out) */
    .gallery-item {
        display: block !important;
        flex: 0 0 82%;
        max-width: 82%;
        width: 82%;
        height: 380px;
        scroll-snap-align: center;
        scroll-snap-stop: normal;
    }

    .gallery-item.is-hidden {
        display: none !important;
    }

    .gallery-zoom-icon {
        opacity: 1;
        transform: scale(0.9);
    }

    /* Reveal Slider Controls on Mobile */
    .gallery-slider-controls {
        display: flex;
    }

    /* Hide desktop pagination bar on mobile */
    .gallery-pagination-wrapper {
        display: none !important;
    }
}

@media (max-width: 576px) {
    .gallery-section {
        padding: 65px 0 60px;
    }

    .gallery-title {
        font-size: 1.85rem;
    }

    .gallery-subtitle {
        font-size: 0.95rem;
    }

    .gallery-bento-grid {
        gap: 14px;
        padding: 8px 12px 20px;
    }

    .gallery-item {
        flex: 0 0 86%;
        max-width: 86%;
        width: 86%;
        height: 330px;
    }

    .gallery-overlay {
        padding: 16px;
    }

    .gallery-item-title {
        font-size: 1.05rem;
        min-height: 2.8em;
    }

    .gallery-portfolio-btn {
        width: 100%;
        justify-content: center;
        padding: 12px 24px;
    }
}

/* Respect Prefers Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .gallery-item,
    .gallery-item:hover,
    .gallery-media-wrapper img,
    .gallery-media-wrapper video,
    .gallery-filter-btn,
    .gallery-zoom-icon,
    .gallery-portfolio-btn,
    .gallery-bento-grid,
    .gallery-slider-arrow,
    .gallery-slider-dot,
    .gallery-page-btn,
    .gallery-page-num,
    .gallery-load-more-btn {
        transition: none !important;
        transform: none !important;
        scroll-behavior: auto !important;
    }
}

/* ==================================================================
   Custom PhotoSwipe 5 Polish for AGHNA Theme
   ================================================================== */
.pswp {
    --pswp-bg: rgba(14, 22, 17, 0.96);
    --pswp-icon-color: #DFCA8D;
    --pswp-icon-color-secondary: #FFFFFF;
}

.pswp__counter {
    color: var(--primary-color, #C5A869);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
}

.pswp__custom-caption {
    background: rgba(14, 22, 17, 0.88);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid rgba(197, 168, 105, 0.3);
    color: #FFFFFF;
    font-size: 1rem;
    padding: 14px 24px;
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    text-align: center;
    max-width: 900px;
    margin: 0 auto;
    border-radius: 12px 12px 0 0;
}

.pswp__custom-caption strong {
    color: var(--primary-color, #C5A869);
    display: block;
    margin-bottom: 4px;
}
