/* Gallery Page Styles - CSS Column Masonry */
.container.limit {
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

.container.limit .divHeader {
    color: var(--bg-color-dark2);
    letter-spacing: 3px;
    font-size: 2.5rem;
    font-weight: bolder;
    margin: 2rem 0;
    border-bottom: 2px solid var(--blue-color);
    animation: showHeader 0.5s;
    text-align: center;
}

.container.limit .categories {
    display: flex;
    gap: 12px;
    margin-bottom: 2rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
}

.container.limit .categories a {
    text-transform: uppercase;
    font-weight: 600;
    padding: 0.5rem 1rem;
    background: #f3f3f3;
    border-radius: 4px;
    text-decoration: none;
    white-space: nowrap;
    color: #333;
    transition: all 0.2s;
    cursor: pointer;
    border: 2px solid transparent;
}

.container.limit .categories a.active,
.container.limit .categories a:hover {
    background: var(--blue-color);
    color: #fff;
    border-color: var(--blue-color);
}

/* CSS Column Masonry Layout */
.gallery-masonry {
    width: 100%;
    margin: 2rem 0;
}

.masonry {
    column-count: 2;
    column-gap: 8px;
    transform: translateZ(0);
    will-change: contents;
}

.item {
    box-sizing: border-box;
    break-inside: avoid;
    margin-bottom: 8px;
    opacity: 0;
    animation: fadeInUp 0.6s ease forwards;
    will-change: opacity, transform;
}

.item.hidden {
    display: none !important;
    visibility: hidden;
    pointer-events: none;
}

.item__content {
    position: relative;
    display: block;
    width: 100%;
    height: 250px;
    min-height: 180px;
    overflow: hidden;
    border-radius: 6px;
    background: #f0f0f0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: height 0.2s ease, box-shadow 0.3s ease, transform 0.3s ease;
    cursor: pointer;
    will-change: transform, box-shadow, height;
    contain: layout style paint;
}

/* Loading state - prevent jumping */
.item__content:not(.item__content--small):not(.item__content--medium):not(.item__content--large) {
    height: 250px;
}

.item__content:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    transform: translateY(-4px);
}

.item__content img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: opacity 0.3s ease, transform 0.4s ease;
    will-change: transform;
    backface-visibility: hidden;
    transform: translateZ(0);
    opacity: 0;
}

.item__content img.loaded {
    opacity: 1;
}

.item__content:hover img {
    transform: scale(1.05);
}

/* Size variations */
.item__content--small {
    height: 180px;
    min-height: 180px;
}

.item__content--medium {
    height: 250px;
    min-height: 250px;
}

.item__content--large {
    height: 320px;
    min-height: 320px;
}

/* Desktop: Ensure all images have minimum height to prevent cropping */
@media screen and (min-width: 800px) {
    .item__content {
        min-height: 360px;
    }
    
    .item__content--small {
        min-height: 360px;
    }
    
    .item__content--medium {
        min-height: 360px;
    }
    
    .item__content--large {
        min-height: 360px;
    }
}

/* Stagger animation for items */
.item:nth-child(1) { animation-delay: 0.05s; }
.item:nth-child(2) { animation-delay: 0.1s; }
.item:nth-child(3) { animation-delay: 0.15s; }
.item:nth-child(4) { animation-delay: 0.2s; }
.item:nth-child(5) { animation-delay: 0.25s; }
.item:nth-child(6) { animation-delay: 0.3s; }
.item:nth-child(n+7) { animation-delay: 0.35s; }

@keyframes showHeader {
    from {
        padding-top: 600px;
        opacity: 0;
    }
    to {
        padding-top: 0;
        opacity: 1;
    }
}

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

/* Responsive Design */
@media screen and (min-width: 400px) {
    .masonry {
        column-count: 2;
    }
}

@media screen and (min-width: 600px) {
    .masonry {
        column-count: 3;
    }
}

@media screen and (min-width: 800px) {
    .masonry {
        column-count: 4;
    }
}

@media screen and (min-width: 1100px) {
    .masonry {
        column-count: 5;
    }
}

@media screen and (max-width: 1024px) {
    .container.limit h2.divHeader {
        font-size: 2rem;
        text-align: center;
    }
    
    .container.limit {
        padding: 1rem;
    }
}

@media screen and (max-width: 600px) {
    .container.limit .categories {
        gap: 8px;
    }
    
    .container.limit .categories a {
        padding: 0.4rem 0.8rem;
        font-size: 0.9rem;
    }
}

@media screen and (max-width: 480px) {
    .container.limit .divHeader {
        font-size: 1.5rem;
        text-align: center;
    }
    
    .masonry {
        column-count: 2;
    }
}

/* Gallery Modal Styles */
.bestoychev-gallery-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 10000;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.bestoychev-gallery-modal.active {
    display: flex;
    opacity: 1;
}

.bestoychev-gallery-modal-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    width: auto;
    height: auto;
}

.bestoychev-gallery-modal-image {
    max-width: 100%;
    max-height: 90vh;
    width: auto;
    height: auto;
    display: block;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.bestoychev-gallery-modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #1f2937;
    z-index: 10001;
    transition: all 0.2s ease;
    font-family: Arial, sans-serif;
    font-weight: bold;
}

.bestoychev-gallery-modal-close:hover {
    background: #ffffff;
    transform: scale(1.1);
}

.bestoychev-gallery-modal-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.9);
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #1f2937;
    z-index: 10001;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.bestoychev-gallery-modal-nav:hover {
    background: #ffffff;
    transform: translateY(-50%) scale(1.1);
}

.bestoychev-gallery-modal-prev {
    left: 20px;
}

.bestoychev-gallery-modal-next {
    right: 20px;
}

.bestoychev-gallery-modal-counter {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: #ffffff;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.875rem;
    z-index: 10001;
}

/* Modal Responsive */
@media screen and (max-width: 768px) {
    .bestoychev-gallery-modal-content {
        max-width: 95vw;
        max-height: 95vh;
    }
    
    .bestoychev-gallery-modal-close,
    .bestoychev-gallery-modal-nav {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }
    
    .bestoychev-gallery-modal-prev {
        left: 10px;
    }
    
    .bestoychev-gallery-modal-next {
        right: 10px;
    }
    
    .bestoychev-gallery-modal-close {
        top: 10px;
        right: 10px;
    }
}
