/**
 * Responsive Images CSS
 * ملف CSS لجعل جميع الصور متجاوبة تماماً على جميع الأجهزة
 * @package Lahzat_News
 * @version 1.0
 */

/* =========================================
   الصور المتجاوبة - تطبيق على جميع الصور
   ========================================= */

/* تطبيق على جميع الصور داخل المحتوى */
.entry-content img,
.post-content img,
article img,
.page-content img {
    max-width: 100% !important;
    height: auto !important;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

/* إزالة أي عرض ثابت من الصور */
.entry-content img[width],
.post-content img[width],
article img[width] {
    width: auto !important;
    max-width: 100% !important;
}

/* الصور داخل الفقرات */
.entry-content p img,
.post-content p img {
    margin: 20px auto;
    display: block;
}

/* =========================================
   الصور على الأجهزة المحمولة
   ========================================= */

@media (max-width: 768px) {
    /* جميع الصور على الموبايل */
    .entry-content img,
    .post-content img,
    article img,
    .page-content img {
        max-width: 100% !important;
        width: 100% !important;
        height: auto !important;
        display: block !important;
        margin-left: auto !important;
        margin-right: auto !important;
        padding: 0 !important;
    }
    
    /* الصور ذات الفئات المحاذية */
    .entry-content .alignleft,
    .entry-content .alignright,
    .entry-content .aligncenter,
    .post-content .alignleft,
    .post-content .alignright,
    .post-content .aligncenter {
        float: none !important;
        margin-left: auto !important;
        margin-right: auto !important;
        display: block !important;
        max-width: 100% !important;
    }
    
    /* الصور داخل الروابط */
    .entry-content a img,
    .post-content a img {
        max-width: 100% !important;
        width: 100% !important;
        height: auto !important;
    }
    
    /* الصور داخل الفقرات على الموبايل */
    .entry-content p img,
    .post-content p img {
        width: 100% !important;
        max-width: 100% !important;
        margin: 15px auto !important;
    }
}

/* =========================================
   تحسينات الصور - تصميم جميل
   ========================================= */

/* إضافة ظل خفيف للصور */
body.images-with-shadow .entry-content img,
body.images-with-shadow .post-content img {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.3s ease;
}

body.images-with-shadow .entry-content img:hover,
body.images-with-shadow .post-content img:hover {
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

/* إضافة حواف للصور */
body.images-with-border .entry-content img,
body.images-with-border .post-content img {
    border: 1px solid #e0e0e0;
    padding: 5px;
}

/* تقريب زوايا الصور */
body.images-rounded .entry-content img,
body.images-rounded .post-content img {
    border-radius: 8px;
    overflow: hidden;
}

/* تأثير التكبير عند التمرير */
body.images-zoom-hover .entry-content img,
body.images-zoom-hover .post-content img {
    transition: transform 0.3s ease;
    cursor: pointer;
}

body.images-zoom-hover .entry-content img:hover,
body.images-zoom-hover .post-content img:hover {
    transform: scale(1.03);
}

/* =========================================
   معارض الصور المحسنة
   ========================================= */

/* معرض الصور الأساسي */
.wp-block-gallery,
.gallery {
    display: grid !important;
    gap: 15px;
    margin: 30px 0;
    padding: 0;
    list-style: none;
}

/* شبكة 3 أعمدة افتراضياً */
.wp-block-gallery,
.gallery {
    grid-template-columns: repeat(3, 1fr);
}

/* شبكة 2 أعمدة */
.gallery-columns-2 {
    grid-template-columns: repeat(2, 1fr) !important;
}

/* شبكة 4 أعمدة */
.gallery-columns-4 {
    grid-template-columns: repeat(4, 1fr) !important;
}

/* شبكة 5 أعمدة */
.gallery-columns-5 {
    grid-template-columns: repeat(5, 1fr) !important;
}

/* شبكة 6 أعمدة */
.gallery-columns-6 {
    grid-template-columns: repeat(6, 1fr) !important;
}

/* عناصر المعرض */
.gallery-item,
.wp-block-gallery .blocks-gallery-item {
    margin: 0 !important;
    padding: 0;
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.gallery-item:hover,
.wp-block-gallery .blocks-gallery-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

/* صور المعرض */
.gallery-item img,
.wp-block-gallery .blocks-gallery-item img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.gallery-item:hover img,
.wp-block-gallery .blocks-gallery-item:hover img {
    transform: scale(1.1);
}

/* التسميات التوضيحية */
.gallery-caption,
.wp-block-gallery .blocks-gallery-item figcaption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
    color: #fff;
    padding: 15px 10px;
    font-size: 13px;
    text-align: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.gallery-item:hover .gallery-caption,
.wp-block-gallery .blocks-gallery-item:hover figcaption {
    opacity: 1;
}

/* =========================================
   معارض الصور على الموبايل
   ========================================= */

@media (max-width: 768px) {
    /* تحويل جميع المعارض إلى عمودين على الموبايل */
    .wp-block-gallery,
    .gallery,
    .gallery-columns-2,
    .gallery-columns-3,
    .gallery-columns-4,
    .gallery-columns-5,
    .gallery-columns-6 {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }
    
    /* التسميات التوضيحية */
    .gallery-caption,
    .wp-block-gallery .blocks-gallery-item figcaption {
        font-size: 11px;
        padding: 10px 5px;
    }
}

@media (max-width: 480px) {
    /* عمود واحد على الشاشات الصغيرة جداً */
    .wp-block-gallery,
    .gallery,
    .gallery-columns-2,
    .gallery-columns-3,
    .gallery-columns-4,
    .gallery-columns-5,
    .gallery-columns-6 {
        grid-template-columns: 1fr !important;
    }
}

/* =========================================
   أنماط المعارض المختلفة
   ========================================= */

/* معرض حديث (Modern) */
.gallery-style-modern .gallery-item {
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 168, 89, 0.15);
}

.gallery-style-modern .gallery-item:hover {
    box-shadow: 0 15px 40px rgba(0, 168, 89, 0.25);
}

/* معرض كلاسيكي (Classic) */
.gallery-style-classic .gallery-item {
    border: 3px solid #f5f5f5;
    border-radius: 0;
    padding: 8px;
    background: #fff;
}

.gallery-style-classic .gallery-item:hover {
    border-color: #00A859;
}

/* معرض بسيط (Minimal) */
.gallery-style-minimal .gallery-item {
    border-radius: 0;
    box-shadow: none;
    border: 1px solid #e0e0e0;
}

.gallery-style-minimal .gallery-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* معرض أنيق (Elegant) */
.gallery-style-elegant .gallery-item {
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
    background: linear-gradient(135deg, #f5f5f5, #ffffff);
    padding: 10px;
}

.gallery-style-elegant .gallery-item:hover {
    background: linear-gradient(135deg, #00A859, #00c46e);
    box-shadow: 0 10px 30px rgba(0, 168, 89, 0.3);
}

/* =========================================
   تأثيرات Hover المختلفة
   ========================================= */

/* تأثير التكبير */
.gallery-hover-zoom .gallery-item img {
    transition: transform 0.4s ease;
}

.gallery-hover-zoom .gallery-item:hover img {
    transform: scale(1.15);
}

/* تأثير التلاشي */
.gallery-hover-fade .gallery-item::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 168, 89, 0.7);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.gallery-hover-fade .gallery-item:hover::after {
    opacity: 1;
}

/* تأثير الانزلاق */
.gallery-hover-slide .gallery-item img {
    transition: transform 0.4s ease;
}

.gallery-hover-slide .gallery-item:hover img {
    transform: translateY(-10px);
}

/* تأثير الضبابية */
.gallery-hover-blur .gallery-item img {
    transition: filter 0.3s ease;
}

.gallery-hover-blur .gallery-item:hover img {
    filter: blur(2px) brightness(0.8);
}

/* =========================================
   أيقونة التكبير
   ========================================= */

.gallery-item.with-zoom-icon::before {
    content: '🔍';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 32px;
    color: #fff;
    background: rgba(0, 168, 89, 0.9);
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 10;
    pointer-events: none;
}

.gallery-item.with-zoom-icon:hover::before {
    opacity: 1;
}

/* =========================================
   Lightbox Support
   ========================================= */

.gallery-item a,
.wp-block-gallery .blocks-gallery-item a {
    display: block;
    position: relative;
}

/* مؤشر الماوس */
.gallery-lightbox-enabled .gallery-item a,
.gallery-lightbox-enabled .wp-block-gallery .blocks-gallery-item a {
    cursor: zoom-in;
}

/* =========================================
   التحميل التدريجي للصور
   ========================================= */

.progressive-image {
    position: relative;
    overflow: hidden;
}

.progressive-image img {
    opacity: 0;
    transition: opacity 0.5s ease;
}

.progressive-image img.loaded {
    opacity: 1;
}

.progressive-image::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* =========================================
   إصلاحات إضافية
   ========================================= */

/* منع الصور من تجاوز الحاويات */
.entry-content,
.post-content {
    overflow-x: hidden;
}

/* الصور ذات الروابط */
.entry-content a img,
.post-content a img {
    display: block;
    margin: 0 auto;
}

/* الصور في القوائم */
.entry-content li img,
.post-content li img {
    max-width: 100%;
    height: auto;
}

/* الصور في الجداول */
.entry-content table img,
.post-content table img {
    max-width: 100%;
    height: auto;
}

/* =========================================
   تحسينات الأداء
   ========================================= */

/* تحسين رسم الصور */
img {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

/* تحميل سلس */
img {
    will-change: transform;
}

/* إزالة الحدود الزرقاء عند التركيز */
.gallery-item a:focus,
.entry-content a img:focus {
    outline: none;
}

/* =========================================
   طباعة الصفحة
   ========================================= */

@media print {
    .entry-content img,
    .post-content img,
    .gallery-item img {
        max-width: 100% !important;
        page-break-inside: avoid;
    }
}

