/**
 * Portfolio Gallery System - Standalone CSS
 * Modern, responsive, CMS-ready gallery with proper mobile viewport handling
 * Version: 2.0
 */

/* ============================================
   GALLERY CONTAINER & GRID
   ============================================ */

.portfolio-gallery {
    width: 100%;
    margin: 0 auto;
}

.gallery-grid {
    display: grid;
    gap: 16px;
    width: 100%;
}

/* Responsive Grid Columns */
@media (max-width: 639px) {
    .gallery-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
}

@media (min-width: 640px) and (max-width: 959px) {
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 14px;
    }
}

@media (min-width: 960px) {
    .gallery-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
    }
}

/* ============================================
   GALLERY ITEMS
   ============================================ */

.gallery-item {
    position: relative;
    width: 100%;
    overflow: hidden;
    border-radius: 8px;
    background-color: #f5f5f5;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.gallery-item::before {
    content: '';
    display: block;
    padding-top: 75%; /* 4:3 aspect ratio */
}

.gallery-item-inner {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.4s ease, opacity 0.3s ease;
}

.gallery-item img.loading {
    opacity: 0;
}

.gallery-item img.loaded {
    opacity: 1;
}

/* Hover Overlay */
.gallery-item-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

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

.gallery-item:hover .gallery-item-overlay {
    opacity: 1;
}

.gallery-item-overlay svg {
    width: 48px;
    height: 48px;
    color: white;
}

/* ============================================
   CATEGORY FILTERS
   ============================================ */

.gallery-filters {
    margin-bottom: 40px;
}

/* Sticky Filters - Vertical Sidebar */
.gallery-filters-sticky {
    position: fixed;
    top: 50%;
    right: 20px;
    transform: translateY(-50%) translateX(120px);
    z-index: 1000;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 12px 8px;
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    opacity: 0;
    transition: opacity 0.5s ease, transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
    max-width: 80px;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.gallery-filters-sticky.visible {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
    pointer-events: all;
}

/* Dark mode sticky filters */
.uk-dark .gallery-filters-sticky {
    background: rgba(30, 35, 48, 0.7);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Sticky filters container */
.gallery-filters-sticky-inner {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
}

/* Sticky filter buttons - vertical style */
.gallery-filters-sticky .gallery-filter-btn {
    width: 56px;
    height: 56px;
    padding: 0;
    margin: 0;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    line-height: 1.2;
    background-color: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(0, 0, 0, 0.05);
    word-wrap: break-word;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.gallery-filters-sticky .gallery-filter-btn:hover {
    background-color: rgba(255, 255, 255, 0.9);
    transform: scale(1.08);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.gallery-filters-sticky .gallery-filter-btn.active {
    background: linear-gradient(135deg, var(--color-primary), #667eea);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

/* Dark mode sticky buttons */
.uk-dark .gallery-filters-sticky .gallery-filter-btn {
    background-color: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
}

.uk-dark .gallery-filters-sticky .gallery-filter-btn:hover {
    background-color: rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.95);
}

.uk-dark .gallery-filters-sticky .gallery-filter-btn.active {
    background: linear-gradient(135deg, var(--color-primary), #667eea);
    color: white;
}

/* Responsive adjustments */
@media (max-width: 1024px) {
    .gallery-filters-sticky {
        right: 12px;
        max-width: 70px;
    }
    
    .gallery-filters-sticky .gallery-filter-btn {
        width: 50px;
        height: 50px;
        font-size: 10px;
        border-radius: 12px;
    }
}

@media (max-width: 768px) {
    .gallery-filters-sticky {
        right: 8px;
        max-width: 60px;
        padding: 10px 6px;
        border-radius: 16px;
    }
    
    .gallery-filters-sticky .gallery-filter-btn {
        width: 44px;
        height: 44px;
        font-size: 9px;
        border-radius: 10px;
    }
    
    .gallery-filters-sticky-inner {
        gap: 6px;
    }
}

@media (max-width: 480px) {
    .gallery-filters-sticky {
        right: 6px;
        max-width: 52px;
        padding: 8px 4px;
        border-radius: 14px;
    }
    
    .gallery-filters-sticky .gallery-filter-btn {
        width: 40px;
        height: 40px;
        font-size: 8px;
        border-radius: 10px;
    }
    
    .gallery-filters-sticky-inner {
        gap: 5px;
    }
}

.gallery-filter-btn {
    padding: 8px 20px;
    margin: 4px;
    border: none;
    background-color: rgba(0, 0, 0, 0.05);
    color: inherit;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 15px;
}

.gallery-filter-btn:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

.gallery-filter-btn.active {
    background-color: var(--color-primary);
    color: white;
}

/* Dark mode filter styles */
.uk-dark .gallery-filter-btn {
    background-color: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
}

.uk-dark .gallery-filter-btn:hover {
    background-color: rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.95);
}

.uk-dark .gallery-filter-btn.active {
    background-color: var(--color-primary);
    color: white;
}

/* ============================================
   LIGHTBOX / MODAL
   ============================================ */

.gallery-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

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

.gallery-lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-lightbox img {
    max-width: 100%;
    max-height: 90vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 4px;
}

/* Lightbox Controls */
.gallery-lightbox-close,
.gallery-lightbox-prev,
.gallery-lightbox-next {
    position: absolute;
    background-color: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 10000;
}

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

.gallery-lightbox-close {
    top: 20px;
    right: 20px;
}

.gallery-lightbox-prev {
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
}

.gallery-lightbox-next {
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
}

.gallery-lightbox-prev:hover,
.gallery-lightbox-next:hover {
    transform: translateY(-50%) scale(1.1);
}

/* Lightbox Caption */
.gallery-lightbox-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 15px 20px;
    text-align: center;
    font-size: 16px;
}

/* Mobile Lightbox Adjustments */
@media (max-width: 639px) {
    .gallery-lightbox-content {
        max-width: 100vw;
        max-height: 85vh;
    }
    
    .gallery-lightbox img {
        max-width: 100vw;
        max-height: 85vh;
    }
    
    .gallery-lightbox-close,
    .gallery-lightbox-prev,
    .gallery-lightbox-next {
        width: 40px;
        height: 40px;
    }
    
    .gallery-lightbox-close {
        top: 10px;
        right: 10px;
    }
    
    .gallery-lightbox-prev {
        left: 10px;
    }
    
    .gallery-lightbox-next {
        right: 10px;
    }
    
    .gallery-lightbox-caption {
        padding: 10px 15px;
        font-size: 14px;
    }
}

/* Prevent body scroll when lightbox is open */
body.gallery-lightbox-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

/* ============================================
   LOADING STATE
   ============================================ */

.gallery-loading {
    text-align: center;
    padding: 40px;
    color: #999;
}

.gallery-empty {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

/* ============================================
   ANIMATIONS
   ============================================ */

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

.gallery-item {
    animation: fadeIn 0.4s ease forwards;
}

.gallery-item:nth-child(1) { animation-delay: 0.05s; }
.gallery-item:nth-child(2) { animation-delay: 0.1s; }
.gallery-item:nth-child(3) { animation-delay: 0.15s; }
.gallery-item:nth-child(4) { animation-delay: 0.2s; }
.gallery-item:nth-child(5) { animation-delay: 0.25s; }
.gallery-item:nth-child(6) { animation-delay: 0.3s; }
