.article-gallery-section {
    direction: var(--direction, ltr);
    margin: 40px 0;
}

.gallery-title {
    font-size: 24px;
    font-weight: 700;
    color: #333;
    margin-bottom: 25px;
    position: relative;
    padding-bottom: 10px;
}

.gallery-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 50px;
    height: 3px;
    background: var(--category-color, #007bff);
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

@media (max-width: 1024px) {
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .gallery-grid {
        grid-template-columns: 1fr;
    }
}

.gallery-item {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    background: #f8f9fa;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    opacity: 0;
    transform: translateY(20px);
    animation: fadeInUp 0.5s ease forwards;
}

.gallery-item:nth-child(1) {
    animation-delay: 0.1s;
}

.gallery-item:nth-child(2) {
    animation-delay: 0.2s;
}

.gallery-item:nth-child(3) {
    animation-delay: 0.3s;
}

.gallery-item:nth-child(4) {
    animation-delay: 0.4s;
}

.gallery-item:nth-child(5) {
    animation-delay: 0.5s;
}

.gallery-item:nth-child(6) {
    animation-delay: 0.6s;
}

.gallery-item:nth-child(7) {
    animation-delay: 0.7s;
}

.gallery-item:nth-child(8) {
    animation-delay: 0.8s;
}

.gallery-item:nth-child(9) {
    animation-delay: 0.9s;
}

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

.gallery-link {
    display: block;
    width: 100%;
    aspect-ratio: 16/9;
    overflow: hidden;
    position: relative;
    text-decoration: none;
}

.gallery-thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.gallery-item:hover .gallery-thumbnail {
    transform: scale(1.05);
}

.gallery-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
    color: white;
    padding: 20px 15px 15px;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

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

.gallery-content {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.gallery-description {
    margin: 0;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

.gallery-views {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    opacity: 0.9;
}

.gallery-views svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
}

.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.599);
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.lightbox:target {
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
}

.lightbox-outer {
    position: relative;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow: auto;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.lightbox:target .lightbox-outer {
    transform: scale(1);
}

.lightbox-inner {
    width: 100%;
    padding: 20px;
}

.lightbox-content {
    width: 100%;
}

.lightbox-content img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
    border-radius: 4px;
}

.lightbox-caption {
    margin-top: 15px;
    padding: 15px 0 0 0;
    border-top: 1px solid #eee;
    max-width: 100%;
}

.lightbox-caption p {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
    color: #fff;
}

.lightbox-prev,
.lightbox-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    text-decoration: none;
    transition: background 0.3s ease, transform 0.3s ease;
    backdrop-filter: blur(10px);
}

.lightbox-prev:hover,
.lightbox-next:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-50%) scale(1.1);
}

.lightbox-prev {
    left: 20px;
    border-radius: 0 4px 4px 0;
}

.lightbox-next {
    right: 20px;
    border-radius: 4px 0 0 4px;
}

.lightbox-prev::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 0;
    height: 0;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-right: 12px solid rgba(255, 255, 255, 0.8);
}

.lightbox-next::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 0;
    height: 0;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-left: 12px solid rgba(255, 255, 255, 0.8);
}

.lightbox-close {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10001;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    text-decoration: none;
    border-radius: 50%;
    transition: background 0.3s ease, transform 0.3s ease;
    backdrop-filter: blur(10px);
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.lightbox-close::before,
.lightbox-close::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 2px;
    background: rgba(255, 255, 255, 0.8);
    transform: translate(-50%, -50%);
}

.lightbox-close::before {
    transform: translate(-50%, -50%) rotate(45deg);
}

.lightbox-close::after {
    transform: translate(-50%, -50%) rotate(-45deg);
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

[dir="rtl"] .gallery-title::after {
    left: auto;
    right: 0;
}

[dir="rtl"] .lightbox-prev {
    left: auto;
    right: 20px;
    border-radius: 4px 0 0 4px;
}

[dir="rtl"] .lightbox-next {
    right: auto;
    left: 20px;
    border-radius: 0 4px 4px 0;
}

[dir="rtl"] .lightbox-prev::before {
    border-right: none;
    border-left: 12px solid rgba(255, 255, 255, 0.8);
}

[dir="rtl"] .lightbox-next::before {
    border-left: none;
    border-right: 12px solid rgba(255, 255, 255, 0.8);
}

@media (max-width: 768px) {
    .gallery-link {
        aspect-ratio: 16/9;
    }

    .lightbox-outer {
        width: 95%;
        max-height: 95vh;
    }

    .lightbox-inner {
        padding: 15px;
    }

    .lightbox-prev,
    .lightbox-next {
        width: 40px;
        height: 40px;
    }

    .lightbox-close {
        width: 35px;
        height: 35px;
    }

    .lightbox-caption {
        margin-top: 10px;
        padding-top: 10px;
    }

    .lightbox-caption p {
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .gallery-description {
        font-size: 13px;
    }

    .lightbox-outer {
        width: 98%;
    }

    .lightbox-inner {
        padding: 10px;
    }

    .lightbox-prev,
    .lightbox-next {
        width: 35px;
        height: 35px;
    }

    .lightbox-close {
        width: 30px;
        height: 30px;
        top: 15px;
        right: 15px;
    }

    [dir="rtl"] .lightbox-close {
        right: auto;
        left: 15px;
    }
}

.no-gallery-items {
    text-align: center;
    padding: 60px 20px;
    color: #6c757d;
    font-size: 16px;
}