/* =====================================================================
   صفحه‌ی عمومی «گالری» (/gallery)
   - دسکتاپ: سه تصویر در هر ردیف ، تبلت: دو تصویر ، موبایل: یک تصویر در هر ردیف
   - فاصله‌ی ثابت از گوشه‌های صفحه و بین کارت‌ها
   - جهت (RTL/LTR) فقط با ویژگی‌های منطقی CSS و dir مربوط به .app-shell تعیین می‌شود
   - همه‌ی قواعد به .app-shell محدود شده‌اند (هم‌خوان با Shop.css و Article.css)
   ===================================================================== */

.app-shell {
    --gal-ease: cubic-bezier(.22, 1, .36, 1);
}

.app-shell .gal-page {
    width: 100%;
    max-width: 1320px;
    margin: 0 auto;
    /* فاصله از گوشه‌ها: روی موبایل ۱۶ و روی دسکتاپ تا ۴۸ پیکسل */
    padding: 22px clamp(16px, 4vw, 48px) 72px;
    box-sizing: border-box;
    position: relative;
    z-index: 1;
}

/* ---------- مسیر صفحه ---------- */
.app-shell .gal-breadcrumb {
    margin-bottom: 18px;
}

.app-shell .gal-breadcrumb ol {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 8px;
    font-size: 13px;
    color: #6b7280;
}

.app-shell .gal-breadcrumb li {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.app-shell .gal-breadcrumb li + li::before {
    content: "‹";
    font-size: 16px;
    line-height: 1;
    color: #a5a3c4;
}

.app-shell[dir="ltr"] .gal-breadcrumb li + li::before {
    content: "›";
}

.app-shell .gal-breadcrumb a {
    color: var(--color-primary-dark, #4338ca);
    font-weight: 500;
}

.app-shell .gal-breadcrumb [aria-current="page"] {
    color: #1e1b4b;
    font-weight: 700;
}

/* ---------- سربرگ ---------- */
.app-shell .gal-hero {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    text-align: center;
    padding: clamp(30px, 5vw, 60px) 18px clamp(26px, 4vw, 46px);
    margin-bottom: clamp(22px, 3.2vw, 40px);
    border-radius: 28px;
    border: 1px solid var(--color-border-light, #ddd6fe);
    background: var(--gradient-mesh, none), linear-gradient(135deg, #eef2ff 0%, #f5f3ff 55%, #fdf4ff 100%);
    box-shadow: 0 10px 34px rgba(99, 102, 241, .12);
}

.app-shell .gal-blob {
    position: absolute;
    z-index: -1;
    border-radius: 50%;
    filter: blur(38px);
    opacity: .55;
    pointer-events: none;
    animation: galFloat 15s ease-in-out infinite alternate;
}

.app-shell .gal-blob-1 {
    width: 220px;
    height: 220px;
    top: -70px;
    inset-inline-start: -50px;
    background: #a5b4fc;
}

.app-shell .gal-blob-2 {
    width: 260px;
    height: 260px;
    bottom: -110px;
    inset-inline-end: 8%;
    background: #f0abfc;
    animation-duration: 19s;
    animation-delay: -4s;
}

.app-shell .gal-blob-3 {
    width: 160px;
    height: 160px;
    top: 18%;
    inset-inline-end: -40px;
    background: #7dd3fc;
    animation-duration: 12s;
    animation-delay: -7s;
}

.app-shell .gal-title {
    margin: 0 0 10px;
    font-size: clamp(28px, 4.8vw, 48px);
    font-weight: 800;
    line-height: 1.3;
    background: var(--gradient-primary, linear-gradient(135deg, #6366f1, #a78bfa));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    animation: galRise .9s var(--gal-ease) both;
}

.app-shell .gal-subtitle {
    max-width: 560px;
    margin: 0 auto;
    font-size: clamp(14px, 1.6vw, 17px);
    line-height: 1.9;
    color: #4b4a6a;
    animation: galRise .9s var(--gal-ease) .12s both;
}

.app-shell .gal-count {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 18px;
    padding: 7px 16px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-primary-dark, #4338ca);
    background: rgba(255, 255, 255, .72);
    border: 1px solid var(--color-border-light, #ddd6fe);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    animation: galRise .9s var(--gal-ease) .24s both;
}

.app-shell .gal-count svg {
    width: 16px;
    height: 16px;
}

/* ---------- شبکه‌ی تصاویر ---------- */
.app-shell .gal-grid {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: clamp(16px, 2.4vw, 32px);
}

/* انیمیشن ورود روی <li> است تا با جابه‌جایی (hover) خود کارت تداخل نکند */
.app-shell .gal-item {
    min-width: 0;
    animation: galRise .8s var(--gal-ease) both;
    animation-delay: calc(var(--i, 0) * 80ms);
}

/* مرورگرهای جدید: هر کارت هنگام رسیدن به صفحه‌ی نمایش (هنگام اسکرول) ظاهر می‌شود */
@supports (animation-timeline: view()) {
    .app-shell .gal-item {
        animation: galRise linear both;
        animation-timeline: view();
        animation-range: entry 0% entry 70%;
    }
}

.app-shell .gal-card {
    position: relative;
    display: block;
    width: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 22px;
    overflow: hidden;
    isolation: isolate;
    aspect-ratio: 4 / 3;
    cursor: zoom-in;
    font: inherit;
    color: inherit;
    text-align: start;
    background: #e9e7fb;
    box-shadow: 0 10px 28px rgba(67, 56, 202, .14);
    transition: transform .5s var(--gal-ease), box-shadow .5s var(--gal-ease);
    -webkit-tap-highlight-color: transparent;
}

/* حلقه‌ی نازک نورانی روی لبه‌ی کارت */
.app-shell .gal-card::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .35);
    pointer-events: none;
    z-index: 2;
}

.app-shell .gal-card:hover,
.app-shell .gal-card:focus-visible {
    transform: translateY(-8px);
    box-shadow: 0 22px 46px rgba(79, 70, 229, .30);
}

.app-shell .gal-card:focus-visible {
    outline: 3px solid var(--color-focus-ring, #a5b4fc);
    outline-offset: 3px;
}

.app-shell .gal-card:active {
    transform: translateY(-3px) scale(.99);
}

/* پس‌زمینه‌ی درخشان تا وقتی عکس بالا می‌آید */
.app-shell .gal-media {
    position: absolute;
    inset: 0;
    background: linear-gradient(100deg, #ece9ff 30%, #f8f6ff 50%, #ece9ff 70%) 0 0 / 220% 100%;
    animation: galShimmer 1.6s linear infinite;
}

.app-shell .gal-media img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scale(1.001);
    transition: transform 1s var(--gal-ease), filter .6s ease;
}

.app-shell .gal-card:hover .gal-media img,
.app-shell .gal-card:focus-visible .gal-media img {
    transform: scale(1.1);
    filter: saturate(1.12) contrast(1.03);
}

.app-shell .gal-overlay {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    padding: 18px;
    background: linear-gradient(to top, rgba(20, 14, 56, .82) 0%, rgba(20, 14, 56, .32) 42%, transparent 72%);
    opacity: 0;
    transform: translateY(14px);
    transition: opacity .45s ease, transform .5s var(--gal-ease);
}

.app-shell .gal-card:hover .gal-overlay,
.app-shell .gal-card:focus-visible .gal-overlay {
    opacity: 1;
    transform: none;
}

.app-shell .gal-caption {
    flex: 1;
    min-width: 0;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.6;
    color: #fff;
    text-shadow: 0 2px 10px rgba(0, 0, 0, .45);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.app-shell .gal-zoom {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    color: #fff;
    background: rgba(255, 255, 255, .2);
    border: 1px solid rgba(255, 255, 255, .4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transform: scale(.6) rotate(-30deg);
    transition: transform .55s cubic-bezier(.34, 1.56, .64, 1);
}

.app-shell .gal-zoom svg {
    width: 22px;
    height: 22px;
}

.app-shell .gal-card:hover .gal-zoom,
.app-shell .gal-card:focus-visible .gal-zoom {
    transform: none;
}

/* صفحه‌ی لمسی (بدون hover): عنوان همیشه پایین کارت دیده می‌شود */
@media (hover: none) {
    .app-shell .gal-overlay {
        opacity: 1;
        transform: none;
        padding: 14px;
        background: linear-gradient(to top, rgba(20, 14, 56, .7) 0%, rgba(20, 14, 56, .12) 40%, transparent 62%);
    }

    .app-shell .gal-zoom {
        display: none;
    }

    .app-shell .gal-card:hover {
        transform: none;
    }
}

/* ---------- اسکلت بارگذاری ---------- */
.app-shell .gal-skeleton {
    aspect-ratio: 4 / 3;
    border-radius: 22px;
    background: linear-gradient(100deg, #ece9ff 30%, #f8f6ff 50%, #ece9ff 70%) 0 0 / 220% 100%;
    animation: galShimmer 1.4s linear infinite;
}

/* ---------- حالت خالی ---------- */
.app-shell .gal-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 6px;
    padding: 56px 16px;
    color: #6b7280;
    border: 2px dashed var(--color-border-light, #ddd6fe);
    border-radius: 24px;
    background: rgba(255, 255, 255, .6);
}

.app-shell .gal-empty svg {
    width: 64px;
    height: 64px;
    margin-bottom: 8px;
    color: var(--color-primary-light, #a5b4fc);
}

.app-shell .gal-empty h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: #1e1b4b;
}

.app-shell .gal-empty p {
    margin: 0;
    font-size: 14px;
}

/* ---------- دکمه‌ی نمایش بیشتر ---------- */
.app-shell .gal-more-wrap {
    display: flex;
    justify-content: center;
    margin-top: clamp(26px, 4vw, 44px);
}

.app-shell .gal-more {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 13px 30px;
    border: 0;
    border-radius: 999px;
    font: inherit;
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    cursor: pointer;
    background: var(--gradient-button, linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%));
    box-shadow: 0 8px 24px rgba(99, 102, 241, .38);
    transition: transform .3s var(--gal-ease), box-shadow .3s var(--gal-ease);
}

.app-shell .gal-more:hover {
    transform: translateY(-3px);
    box-shadow: 0 14px 32px rgba(99, 102, 241, .5);
}

.app-shell .gal-more:focus-visible {
    outline: 3px solid var(--color-focus-ring, #a5b4fc);
    outline-offset: 3px;
}

.app-shell .gal-more-badge {
    min-width: 26px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    text-align: center;
    background: rgba(255, 255, 255, .25);
}

/* ---------- Lightbox ---------- */
body:has(.gal-lightbox) {
    overflow: hidden; /* اسکرول صفحه‌ی پشت لایت‌باکس قفل می‌شود */
}

.app-shell .gal-lightbox {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: grid;
    place-items: center;
    padding: clamp(12px, 3vw, 40px);
    background: rgba(12, 9, 34, .88);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    outline: none;
    animation: galFadeIn .3s ease both;
}

.app-shell .gal-lb-figure {
    margin: 0;
    max-width: min(1200px, 100%);
    max-height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    touch-action: pan-y;
    user-select: none;
    -webkit-user-select: none;
}

.app-shell .gal-lb-img {
    display: block;
    max-width: 100%;
    max-height: calc(100vh - 170px);
    max-height: calc(100dvh - 170px);
    object-fit: contain;
    border-radius: 18px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, .55);
    animation: galZoomIn .5s var(--gal-ease) both;
}

.app-shell .gal-lb-caption {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px 14px;
    text-align: center;
    color: #fff;
    animation: galRise .6s var(--gal-ease) .1s both;
}

.app-shell .gal-lb-title {
    font-size: clamp(14px, 1.8vw, 17px);
    font-weight: 700;
}

.app-shell .gal-lb-counter {
    padding: 3px 12px;
    border-radius: 999px;
    font-size: 12px;
    background: rgba(255, 255, 255, .16);
}

.app-shell .gal-lb-btn {
    position: absolute;
    z-index: 1;
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    padding: 0;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    background: rgba(255, 255, 255, .12);
    border: 1px solid rgba(255, 255, 255, .3);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: transform .25s var(--gal-ease), background .25s ease;
}

.app-shell .gal-lb-btn:hover {
    background: rgba(255, 255, 255, .26);
    transform: scale(1.08);
}

.app-shell .gal-lb-btn:focus-visible {
    outline: 3px solid var(--color-focus-ring, #a5b4fc);
    outline-offset: 2px;
}

.app-shell .gal-lb-btn svg {
    width: 24px;
    height: 24px;
}

.app-shell .gal-lb-close {
    top: 18px;
    inset-inline-end: 18px;
}

/* «قبلی» در ابتدای خط و «بعدی» در انتهای خط است؛ در RTL جای آن‌ها و جهت فلش‌ها خودکار برعکس می‌شود */
.app-shell .gal-lb-prev {
    top: 50%;
    inset-inline-start: 18px;
    margin-top: -26px;
}

.app-shell .gal-lb-next {
    top: 50%;
    inset-inline-end: 18px;
    margin-top: -26px;
}

.app-shell[dir="rtl"] .gal-lb-prev svg,
.app-shell[dir="rtl"] .gal-lb-next svg {
    transform: scaleX(-1);
}

/* ---------- ریسپانسیو ---------- */
/* تبلت: دو تصویر در هر ردیف */
@media (max-width: 1023px) {
    .app-shell .gal-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* موبایل: یک تصویر در هر ردیف */
@media (max-width: 639px) {
    .app-shell .gal-page {
        padding-top: 14px;
        padding-bottom: 56px;
    }

    .app-shell .gal-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 18px;
    }

    .app-shell .gal-hero {
        border-radius: 22px;
    }

    .app-shell .gal-card,
    .app-shell .gal-skeleton {
        border-radius: 18px;
    }

    .app-shell .gal-lb-btn {
        width: 44px;
        height: 44px;
    }

    /* دکمه‌های قبلی/بعدی پایین صفحه، تا روی تصویر نیفتند */
    .app-shell .gal-lb-prev,
    .app-shell .gal-lb-next {
        top: auto;
        bottom: 18px;
        margin-top: 0;
    }

    .app-shell .gal-lb-close {
        top: 12px;
        inset-inline-end: 12px;
    }

    .app-shell .gal-lb-img {
        max-height: calc(100vh - 200px);
        max-height: calc(100dvh - 200px);
    }
}

/* ---------- انیمیشن‌ها ---------- */
@keyframes galRise {
    from {
        opacity: 0;
        transform: translateY(38px) scale(.96);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

@keyframes galFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes galZoomIn {
    from {
        opacity: 0;
        transform: scale(.9) translateY(14px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

@keyframes galShimmer {
    from { background-position: 120% 0; }
    to { background-position: -100% 0; }
}

@keyframes galFloat {
    from { transform: translate3d(0, 0, 0) scale(1); }
    to { transform: translate3d(34px, 26px, 0) scale(1.14); }
}

/* کاربرانی که حرکت کمتر را در سیستم‌عامل انتخاب کرده‌اند */
@media (prefers-reduced-motion: reduce) {
    .app-shell .gal-item,
    .app-shell .gal-title,
    .app-shell .gal-subtitle,
    .app-shell .gal-count,
    .app-shell .gal-blob,
    .app-shell .gal-media,
    .app-shell .gal-skeleton,
    .app-shell .gal-lightbox,
    .app-shell .gal-lb-img,
    .app-shell .gal-lb-caption {
        animation: none !important;
    }

    .app-shell .gal-card,
    .app-shell .gal-media img,
    .app-shell .gal-overlay,
    .app-shell .gal-zoom,
    .app-shell .gal-more,
    .app-shell .gal-lb-btn {
        transition: none !important;
    }
}
