/* =========================================
   VOM Lab - Gallery Page Styles
   ========================================= */

/* =========================================
   1. Gallery Section
   ========================================= */
.gallery-section {
    padding-top: 20px;
    padding-bottom: 100px;
}

.loading-text {
    text-align: center;
    color: var(--text-secondary);
    grid-column: 1 / -1;
}

/* =========================================
   2. Gallery Grid
   ========================================= */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

/* =========================================
   3. Gallery Item Card
   ========================================= */
.gallery-item {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    background: #f8f9fa;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 1px solid var(--border-color);
}

.gallery-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
    border-color: transparent;
}

/* Image Container - Aspect Ratio 유지 */
.gallery-img-wrap {
    position: relative;
    width: 100%;
    padding-bottom: 75%; /* 4:3 비율 */
    overflow: hidden;
    background: #eee;
}

.gallery-img-wrap img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease, opacity 0.3s ease;
    /* 로딩 최적화 */
    content-visibility: auto;
}

/* 로딩 중 placeholder */
.gallery-img-wrap::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
    background-size: 200% 200%;
    animation: shimmer 1.5s infinite;
    z-index: 1;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.gallery-img-wrap.loaded::before {
    opacity: 0;
    pointer-events: none;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* 마우스 오버 시 이미지 확대 */
.gallery-item:hover .gallery-img-wrap img {
    transform: scale(1.08);
}

/* Overlay */
.gallery-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 20px 15px 15px;
    background: linear-gradient(to top, rgba(0,0,0,0.7) 0%, rgba(0,0,0,0) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

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

.gallery-title {
    color: #fff;
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.4;
    text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* =========================================
   4. Lightbox Modal
   ========================================= */
.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

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

.lightbox.fade-in {
    opacity: 1;
}

/* Close Button */
.lightbox-close {
    position: absolute;
    top: 20px;
    right: 30px;
    font-size: 40px;
    color: #fff;
    background: none;
    border: none;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 10001;
    line-height: 1;
}

.lightbox-close:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* Navigation Buttons */
.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 50px;
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    cursor: pointer;
    padding: 20px 15px;
    opacity: 0.7;
    transition: all 0.2s ease;
    z-index: 10001;
    border-radius: 4px;
}

.lightbox-nav:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.2);
}

.lightbox-prev {
    left: 20px;
}

.lightbox-next {
    right: 20px;
}

/* Content */
.lightbox-content {
    max-width: 90%;
    max-height: 80vh;
    text-align: center;
    position: relative;
}

#lightbox-img {
    max-width: 100%;
    max-height: 75vh;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

#lightbox-img.loaded {
    opacity: 1;
    transform: scale(1);
}

/* Caption */
.lightbox-caption {
    margin-top: 20px;
    color: #fff;
    font-size: 1rem;
    font-weight: 400;
    opacity: 0.9;
}

/* Counter */
.lightbox-counter {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.9rem;
    font-variant-numeric: tabular-nums;
}

/* Loading Spinner for Lightbox */
.lightbox-content::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    opacity: 1;
    transition: opacity 0.3s;
}

.lightbox-content.loaded::before {
    opacity: 0;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* =========================================
   5. Responsive
   ========================================= */
@media (max-width: 1200px) {
    .gallery-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 900px) {
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    .lightbox-nav {
        font-size: 36px;
        padding: 15px 10px;
    }
    
    .lightbox-prev { left: 10px; }
    .lightbox-next { right: 10px; }
    
    .lightbox-close {
        top: 15px;
        right: 20px;
        font-size: 32px;
    }
}

@media (max-width: 600px) {
    .gallery-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .gallery-section {
        padding-bottom: 60px;
    }
    
    .gallery-img-wrap {
        padding-bottom: 66.67%; /* 3:2 비율 - 모바일에서 더 넓게 */
    }
    
    .gallery-overlay {
        opacity: 1; /* 모바일에서는 항상 보이게 */
        padding: 15px 12px 12px;
    }
    
    .gallery-title {
        font-size: 0.85rem;
    }
    
    .lightbox-nav {
        font-size: 28px;
        padding: 12px 8px;
    }
    
    .lightbox-close {
        font-size: 28px;
        top: 10px;
        right: 15px;
    }
    
    .lightbox-caption {
        font-size: 0.9rem;
        padding: 0 15px;
    }
}

/* =========================================
   6. Touch Device Optimization
   ========================================= */
@media (hover: none) {
    .gallery-overlay {
        opacity: 1;
    }
    
    .gallery-item:hover {
        transform: none;
    }
    
    .gallery-item:active {
        transform: scale(0.98);
    }
}

/* =========================================
   7. Animation for Grid Items
   ========================================= */
.gallery-item {
    opacity: 0;
    transform: translateY(20px);
    animation: fadeInUp 0.5s ease forwards;
}

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

/* Staggered animation delay */
.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; }
.gallery-item:nth-child(7) { animation-delay: 0.35s; }
.gallery-item:nth-child(8) { animation-delay: 0.4s; }
.gallery-item:nth-child(9) { animation-delay: 0.45s; }
.gallery-item:nth-child(10) { animation-delay: 0.5s; }
.gallery-item:nth-child(11) { animation-delay: 0.55s; }
.gallery-item:nth-child(12) { animation-delay: 0.6s; }

/* Body scroll lock when lightbox is open */
body.lightbox-open {
    overflow: hidden;
}


/* gallery.css 파일 맨 아래에 추가하세요 */

/* =========================================
   8. Hidden Gallery Action (New)
   ========================================= */
.gallery-actions {
    display: flex;
    justify-content: center;
    margin-top: 50px;
    padding-bottom: 20px;
}

.firework-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    background: #fff;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.firework-icon {
    font-size: 28px;
    line-height: 1;
    display: block;
    transition: transform 0.3s ease;
}

/* Hover Effects */
.firework-btn:hover {
    transform: translateY(-3px) scale(1.1);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
    background: #f8f9fa;
}

.firework-btn:hover .firework-icon {
    animation: shake 0.5s ease-in-out;
}

/* Click/Active Effect */
.firework-btn:active {
    transform: translateY(0) scale(0.95);
}

/* Hide button when clicked (class added by JS) */
.gallery-actions.hidden {
    display: none;
}

@keyframes shake {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-15deg); }
    75% { transform: rotate(15deg); }
}

/* gallery.css 맨 아래에 추가 */

/* 숨겨진 이미지가 등장할 때의 애니메이션 */
.gallery-item.reveal-enter {
    animation: popIn 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes popIn {
    0% {
        opacity: 0;
        transform: scale(0.5) translateY(30px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}