/* ========================================
   گالری ستونی - Base
======================================== */

.cgw-gallery {
    display: grid;
    width: 100%;
}

/* ========================================
   آیتم گالری
======================================== */

.cgw-item {
    position: relative !important;
    overflow: hidden !important;
    border-radius: 8px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), 
                box-shadow 0.3s ease;
}

.cgw-item:hover {
    transform: translateY(-8px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.3);
}

/* ========================================
   لینک
======================================== */

.cgw-link {
    display: block !important;
    text-decoration: none !important;
    color: inherit !important;
    position: relative !important;
}

/* ========================================
   Wrapper تصویر - کلیدی!
======================================== */

.cgw-image-wrapper {
    position: relative !important;
    width: 100% !important;
    height: 100% !important;
    overflow: hidden !important;
    display: block !important;
}

/* ========================================
   تصویر
======================================== */

.cgw-image {
    width: 100% !important;
    height: 100% !important;
    display: block !important;
    object-fit: cover !important;
    
    /* سیاه و سفید */
    filter: grayscale(100%) brightness(0.9) !important;
    
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1),
                filter 0.6s ease !important;
    
    position: relative !important;
    z-index: 1 !important;
}

.cgw-item:hover .cgw-image {
    transform: scale(1.15) !important;
    filter: grayscale(0%) brightness(1) !important;
}

/* ========================================
   اورلی - مستقیماً روی تصویر
======================================== */

.cgw-overlay {
    /* فورس position absolute */
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    
    /* پس‌زمینه تیره */
    background: linear-gradient(
        to top,
        rgba(0, 0, 0, 0.85) 0%,
        rgba(0, 0, 0, 0.4) 50%,
        rgba(0, 0, 0, 0) 100%
    ) !important;
    
    /* مخفی در حالت عادی */
    opacity: 0 !important;
    
    /* انیمیشن */
    transition: opacity 0.4s ease !important;
    
    /* Layout */
    display: flex !important;
    align-items: flex-end !important;
    justify-content: flex-start !important;
    padding: 30px 25px !important;
    
    /* بالای تصویر */
    z-index: 10 !important;
    
    /* فورس layer جدید */
    transform: translateZ(0) !important;
}

.cgw-item:hover .cgw-overlay {
    opacity: 1 !important;
}

/* ========================================
   محتوا
======================================== */

.cgw-content {
    width: 100% !important;
    position: relative !important;
    
    /* انیمیشن ورود از پایین */
    transform: translateY(30px) !important;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1) !important;
    
    z-index: 11 !important;
}

.cgw-item:hover .cgw-content {
    transform: translateY(0) !important;
}

/* ========================================
   عنوان
======================================== */

.cgw-title {
    margin: 0 0 12px 0 !important;
    padding: 0 !important;
    font-weight: 700 !important;
    line-height: 1.3 !important;
    color: #ffffff !important;
    font-size: 1.5rem !important;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.6) !important;
    
    /* انیمیشن جداگانه */
    opacity: 0 !important;
    transform: translateY(15px) !important;
    transition: opacity 0.4s ease 0.1s,
                transform 0.4s ease 0.1s !important;
    
    position: relative !important;
    z-index: 12 !important;
}

.cgw-item:hover .cgw-title {
    opacity: 1 !important;
    transform: translateY(0) !important;
}

/* ========================================
   توضیحات
======================================== */

.cgw-caption {
    margin: 0 !important;
    padding: 0 !important;
    line-height: 1.6 !important;
    color: rgba(255, 255, 255, 0.95) !important;
    font-size: 1rem !important;
    text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6) !important;
    
    /* انیمیشن جداگانه */
    opacity: 0 !important;
    transform: translateY(15px) !important;
    transition: opacity 0.4s ease 0.2s,
                transform 0.4s ease 0.2s !important;
    
    position: relative !important;
    z-index: 12 !important;
}

.cgw-item:hover .cgw-caption {
    opacity: 1 !important;
    transform: translateY(0) !important;
}

/* ========================================
   فورس کردن - اضافی
======================================== */

/* اطمینان کامل از positioning */
.cgw-gallery .cgw-item {
    position: relative !important;
}

.cgw-gallery .cgw-image-wrapper {
    position: relative !important;
}

.cgw-gallery .cgw-overlay {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
}

/* حذف هرگونه float */
.cgw-gallery .cgw-content,
.cgw-gallery .cgw-title,
.cgw-gallery .cgw-caption {
    float: none !important;
    clear: none !important;
    position: relative !important;
}

/* ========================================
   تست - بعداً حذف کنید
======================================== */


/* ========================================
   JavaScript Fallback
======================================== */

/* اگر JS لازم باشد */
.cgw-overlay[style*="position: static"] {
    position: absolute !important;
}

/* ========================================
   ریسپانسیو
======================================== */

@media (max-width: 1024px) {
    .cgw-overlay {
        padding: 25px 20px !important;
    }
    
    .cgw-title {
        font-size: 1.35rem !important;
    }
    
    .cgw-caption {
        font-size: 0.95rem !important;
    }
}

@media (max-width: 768px) {
    .cgw-gallery {
        gap: 15px !important;
    }
    
    .cgw-overlay {
        padding: 20px 18px !important;
    }
    
    .cgw-title {
        font-size: 1.25rem !important;
        margin-bottom: 10px !important;
    }
    
    .cgw-caption {
        font-size: 0.9rem !important;
    }
    
    .cgw-item:hover {
        transform: translateY(-5px) !important;
    }
    
    .cgw-item:hover .cgw-image {
        transform: scale(1.1) !important;
    }
}

@media (max-width: 480px) {
    .cgw-overlay {
        padding: 18px 15px !important;
    }
    
    .cgw-title {
        font-size: 1.15rem !important;
        margin-bottom: 8px !important;
    }
    
    .cgw-caption {
        font-size: 0.875rem !important;
    }
}

/* ========================================
   دسترسی‌پذیری
======================================== */

.cgw-item:focus-within .cgw-overlay {
    opacity: 1 !important;
}

.cgw-item:focus-within .cgw-content {
    transform: translateY(0) !important;
}

.cgw-item:focus-within .cgw-title,
.cgw-item:focus-within .cgw-caption {
    opacity: 1 !important;
    transform: translateY(0) !important;
}

.cgw-item:focus-within .cgw-image {
    transform: scale(1.15) !important;
    filter: grayscale(0%) brightness(1) !important;
}

/* ========================================
   بهینه‌سازی عملکرد
======================================== */

.cgw-image,
.cgw-overlay,
.cgw-content,
.cgw-title,
.cgw-caption {
    will-change: transform, opacity, filter;
}

/* حذف انیمیشن برای کاربران حساس به حرکت */
@media (prefers-reduced-motion: reduce) {
    .cgw-item,
    .cgw-image,
    .cgw-overlay,
    .cgw-content,
    .cgw-title,
    .cgw-caption {
        transition: none !important;
    }
}