
/* --- Optimized demo-gallery styles --- */
.demo-gallery {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start; /* without this, flexbox's default "stretch"
        forces every item in a row to match its tallest sibling's height,
        which silently overrides each item's own aspect-ratio (1-1/2-1/1-2) */
    padding-bottom: 60px;
    max-width: 1200px;
    margin: 0 auto;
}


.demo-gallery > ul {
    margin: 0;
    padding: 0;
    list-style: none;
    max-width: 90vw;
    margin: 0 auto;
    direction: ltr;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
}
.image-container {
    max-width: 90vw;
}
.demo-gallery > ul > li {
    max-width: 200px;  
    flex: 0 0 180px;  
}

.demo-gallery ul li {
    position: relative;
    width: 160px;
    aspect-ratio: 16/9;
    overflow: hidden;
    border-radius: 16px;
    flex: 0 0 auto;
}

.demo-gallery > ul > li a {
    display: block;
    width: 100%;
    height: 100%;
    overflow: hidden;
    border-radius: 16px !important;
    position: relative;
    z-index: 1;
    border: none;
}

.demo-gallery > ul > li a > img,
.demo-gallery .justified-gallery > a > img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 16px !important;
    transition: transform 0.15s ease;
    transform: scale3d(1, 1, 1);
}

.demo-gallery > ul > li a:hover > img,
.demo-gallery .justified-gallery > a:hover > img {
    transform: scale3d(1.1, 1.1, 1.1);
    filter: blur(2px);
}

.demo-gallery .image-title {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 18px;
    font-weight: bold;
    color: black;
    white-space: nowrap;
    text-shadow:
        -0.5px -0.5px 0 white,
         0.5px -0.5px 0 white,
        -0.5px  0.5px 0 white,
         0.5px  0.5px 0 white;
    opacity: 0;
    z-index: 5;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.demo-gallery > ul > li a:hover .image-title {
    opacity: 1;
}

/* Poster overlay */
.demo-gallery .demo-gallery-poster,
.demo-gallery > ul > li a .demo-gallery-poster,
.demo-gallery .justified-gallery > a .demo-gallery-poster {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(0, 0, 0, 0.1);
    transition: background-color 0.15s ease;
    pointer-events: none !important;
    user-select: none !important;
    z-index: 2;
}

.demo-gallery > ul > li a:hover .demo-gallery-poster,
.demo-gallery .justified-gallery > a:hover .demo-gallery-poster {
    background-color: rgba(0, 0, 0, 0.5);
}

.demo-gallery > ul > li a .demo-gallery-poster > img,
.demo-gallery .justified-gallery > a .demo-gallery-poster > img {
    position: absolute;
    top: 50%;
    left: 50%;
    opacity: 0;
    transition: opacity 0.3s ease;
    transform: translate(-50%, -50%);
}

.demo-gallery > ul > li a:hover .demo-gallery-poster > img,
.demo-gallery .justified-gallery > a:hover .demo-gallery-poster > img {
    opacity: 1;
}
@media (max-width: 992px) {
    .demo-gallery > ul > li {
        flex: 1 1 calc(33.33% - 15px);
    }
}

@media (max-width: 768px) {
    .demo-gallery > ul > li {
        flex: 1 1 calc(50% - 15px);
        border-radius: 15px;
    }
}

@media (max-width: 480px) {
    .demo-gallery > ul > li {
        flex: 1 1 100%;
        border-radius: 12px;
    }
}
@media (min-width: 1600px) {
    .demo-gallery > ul {
        max-width: 1400px;
    }
}

/* --- Video Icon Style --- */
.demo-gallery .video .demo-gallery-poster img {
    width: 48px;
    height: 48px;
    margin-left: -24px;
    margin-top: -24px;
    opacity: 0.8;
}

/* --- Dark Theme Border --- */
.demo-gallery.dark > ul > li a {
    border: 3px solid #04070a;
}

/* The old .category-menu / .menu-toggle / .category-dropdown-wrapper rules
   that used to live here were replaced by the single glassmorphism panel
   implementation in front/css/gallery-filter.css — see that file. The old
   base rule's "transition: all 0.5s ease" was the root cause of a visible
   layout-property glitch on open (looked like two different menus
   flashing); the new panel only ever transitions transform/opacity. */


/* --- Single Image View --- */
.image-wrapper.single-gallery {
    text-align: center;
    padding-top: 50px;
}

.image-container {
    display: inline-block;
    position: relative;
    max-width: 90vw;
}

.gallery-image {
    display: block;
    max-width: 100%;
    max-height: 80vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 16px;
}

.gallery-description {
    max-width: 700px;
    margin: 24px auto 0;
    padding: 0 16px;
    text-align: right;
    direction: rtl;
}

.gallery-description p {
    margin: 0;
    color: var(--color-two, #cfcfcf);
    font-size: 15px;
    line-height: 28px;
}

/* هدر سفید بالای عکس با عرض خود عکس */
.gallery-header {
    position: absolute;
    bottom: 0;
    right: 0;
    left: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0);
    backdrop-filter: blur(3px);
    border-radius: 0;
    padding: 10px 16px;
    box-sizing: border-box;
    z-index: 10;
    width: 100%;
    margin: 0;
    height: 70px;
}

.header-title {
    display: inline-block;
    text-align: right;
    direction: rtl;
}

.header-title h1 {
    font-size: 16px;
    margin: 0;
    font-family: 'estedad-lightbold';
    /* white-space: nowrap; */
    padding: 0;
    height: auto;
    line-height: 1.3;
}

.header-title small {
    font-size: 12px;
    font-family: 'estedad-light';
    color: #555;
    white-space: nowrap;
}

.header-like-btn {
    background: none;
    border: none;
    font-size: 20px;
    color: #d11a2a;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    flex-shrink: 0;
    /* حذف margin-top و اضافه کردن align-self */
    align-self: center;
    margin: 0;
    padding: 12px;
    margin: -12px;
    min-width: 44px;
    min-height: 44px;
}

.header-like-btn:hover {
    opacity: 0.8;
}
/* موبایل */
@media (max-width: 600px) {
    .gallery-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        padding: 8px 12px;
    }

    .header-title h1 {
        font-size: 14px;
    }

    .header-title small {
        font-size: 11px;
    }

    .header-like-btn {
        font-size: 18px;
    }
}

/* دکمه‌های چپ و راست */
.arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,0.3);
    backdrop-filter: blur(8px);
    border: none;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #fff;
    opacity: 0.6;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 10;
}

.arrow:hover {
    opacity: 1;
    transform: translateY(-50%) scale(1.1);
}

.arrow-prev { left: 8px; }
.arrow-next { right: 8px; }

/* --- Gallery Thumbnails (in list view) --- */

/* --- Gallery Item Layout --- */
.gallery-item {
    width: 100%;
    max-width: 160px;
    aspect-ratio: 16 / 9 !important;
    border-radius: 16px;
    overflow: hidden;
    position: relative;
    flex: 0 0 auto;
}

/* Guarantee 2 columns on phones. Needs !important + the same ancestry
   specificity as the older ".demo-gallery > ul > li" rule below, because
   the actual markup has an outer <div class="demo-gallery"> wrapping the
   <ul class="demo-gallery">, so that older selector really does match here
   (it looks dead at a glance, but it isn't) and otherwise wins the cascade. */
@media (max-width: 480px) {
    .gallery-item,
    .demo-gallery > ul > li.gallery-item {
        flex: 1 1 calc(50% - 8px) !important;
        max-width: calc(50% - 8px) !important;
    }
}
.gallery-thumb {
    width: 100%;
    height: 100%;
    object-fit: contain !important;
    position: relative;
    z-index: 2;
    border-radius: 16px;
}
.gallery-item a {
    display: block;
    width: 100%;
    height: 100%;
    position: relative;
}

.gallery-item .blur-background {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-size: cover;
    background-position: center;
    filter: blur(3px);
    transform: scale(1.06);
    z-index: 1;
}

.gallery-item .gallery-thumb {
    position: relative;
    z-index: 2;
    object-fit: contain;
    border-radius: 16px;
    width: 100%;
    height: 100%;
}

.gallery-item:hover .gallery-thumb {
    filter: blur(1.5px);
}

.gallery-thumb.contain-thumb {
    object-fit: contain !important;
    background-color: transparent;
    z-index: 2;
}

/* --- Aspect Ratio Helpers --- */
.aspect-2-1,
.gallery-item.aspect-2-1 { aspect-ratio: 16 / 9 !important; }
.aspect-1-2,
.gallery-item.aspect-1-2 { aspect-ratio: 9 / 16 !important; }
.aspect-1-1,
.gallery-item.aspect-1-1 { aspect-ratio: 1 / 1 !important; }

.gallery-item:not([class*="aspect-"]) {
    aspect-ratio: 3 / 5;
}
.page-banner .banner-title {
    font-family: inherit !important;
    font-size: 32px;
    font-weight: bold;
    text-shadow: 0 0 6px rgba(0, 0, 0, 0.6);
    margin: 0;
    color: #fff;
}
/* کاهش فاصله زیر بنر */
.wptb-page-heading {
    margin-bottom: 0 !important;
    padding-bottom: 0 !important;
}

/* حذف فاصله بالای سکشن */
.wptb-page-heading + section {
    margin-top: 0 !important;
    padding-top: 0 !important;
}

/* حذف فاصله احتمالی از کانتینر */
section .container:first-child {
    margin-top: 0 !important;
    padding-top: 0 !important;
}
